Skip to content

media: Wire URL player duration and buffered ranges for tvOS - #11548

Open
abhijeetk wants to merge 2 commits into
youtube:mainfrom
abhijeetk:wiring-up-duration-and-buffer-ranges
Open

media: Wire URL player duration and buffered ranges for tvOS#11548
abhijeetk wants to merge 2 commits into
youtube:mainfrom
abhijeetk:wiring-up-duration-and-buffer-ranges

Conversation

@abhijeetk

@abhijeetk abhijeetk commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Plumb duration and buffered time range reporting from the URL player
through StarboardRenderer, StarboardRendererWrapper, Mojo IPC, and
UrlPlayerDemuxer. This ensures that the JavaScript video.duration and
video.buffered APIs correctly reflect the underlying platform player
state on tvOS.

Duration is reported once when the player reaches the presenting state.
Buffered ranges are polled via GetMediaTime on each timer tick to
provide continuous updates to the web application.

Blocked by #10698

Bug: 512045535

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


media: Wire URL player duration and buffered ranges

Plumb duration and buffered time range reporting from the URL player
through StarboardRenderer, StarboardRendererWrapper, Mojo IPC, and
UrlPlayerDemuxer. This ensures that the JavaScript video.duration and
video.buffered APIs correctly reflect the underlying platform player
state on tvOS.

Duration is reported once when the player reaches the presenting state.
Buffered ranges are polled via GetMediaTime on each timer tick to
provide continuous updates to the web application.

Bug: 512045535

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@abhijeetk abhijeetk self-assigned this Jul 25, 2026
@abhijeetk

Copy link
Copy Markdown
Collaborator Author

cc : @Gyuyoung @jkim-julie @rakuco

@abhijeetk
abhijeetk marked this pull request as ready for review July 27, 2026 19:11
@abhijeetk
abhijeetk requested review from a team as code owners July 27, 2026 19:11

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for a URL-based player (URL player) on iOS/tvOS platforms using Starboard media, adding UrlPlayerDemuxer and UrlPlayerDemuxerStream as placeholders, and integrating them with StarboardRenderer and StarboardRendererClient. The review feedback recommends adding class comments to the new classes per the style guide, adding defensive null checks for player_bridge_ to prevent potential crashes, using DCHECK instead of CHECK for sequence verification, and aligning preprocessor guards to BUILDFLAG(IS_IOS_TVOS) && BUILDFLAG(USE_STARBOARD_MEDIA) to avoid compilation failures in non-Starboard configurations.

Comment thread media/starboard/url_player_demuxer.h
Comment thread media/starboard/url_player_demuxer.h
Comment thread media/starboard/starboard_renderer.cc Outdated
Comment thread media/starboard/starboard_renderer.cc
Comment thread media/starboard/starboard_renderer.cc
Comment thread media/mojo/clients/starboard/starboard_renderer_client.cc
Comment thread media/mojo/clients/starboard/starboard_renderer_client.cc
Comment thread media/mojo/clients/starboard/starboard_renderer_client.cc
Comment thread media/mojo/clients/starboard/starboard_renderer_client.cc
Comment thread media/mojo/clients/starboard/starboard_renderer_client.cc
Add URL player support to StarboardRenderer for native HLS playback.
UrlPlayerDemuxer provides placeholder streams for pipeline init while
the platform player handles actual playback via SetSourceUrl.

Bug: 512045535
through StarboardRenderer, StarboardRendererWrapper, Mojo IPC, and
UrlPlayerDemuxer. This ensures that the JavaScript video.duration and
video.buffered APIs correctly reflect the underlying platform player
state on tvOS.

Duration is reported once when the player reaches the presenting state.
Buffered ranges are polled via GetMediaTime on each timer tick to
provide continuous updates to the web application.

Blocked by youtube#10698

Bug: 512045535
@abhijeetk
abhijeetk force-pushed the wiring-up-duration-and-buffer-ranges branch from 995ec4c to 4d11882 Compare July 28, 2026 19:00
#include "media/base/media_switches.h"
#include "media/base/renderer_factory.h"
#include "media/base/starboard/experimental_features.h"
#include "media/media_buildflags.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think including this is necessary.

@borongc borongc Jul 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments of this PR should be applied to #10698.

#include "third_party/blink/public/web/web_view.h"
#include "ui/gfx/geometry/size_conversions.h"

#if BUILDFLAG(IS_IOS_TVOS) && BUILDFLAG(USE_STARBOARD_MEDIA)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

USE_STARBOARD_MEDIA is true for Cobalt build anyway, so this is not necessary.

Comment thread media/base/demuxer.h
kFrameInjectingDemuxer = 5,
kStreamProviderDemuxer = 6,
kManifestDemuxer = 7,
kUrlPlayerDemuxer = 8, // URL player placeholder demuxer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: gate it by BUILDFLAG(USE_STARBOARD_MEDIA).

#include "media/base/media_resource.h"

#include "base/no_destructor.h"
#include "media/media_buildflags.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary, please check it.

#include "media/base/demuxer_stream.h"
#include "media/base/media_export.h"
#include "build/build_config.h"
#include "media/media_buildflags.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for all #include "media/media_buildflags.h"


if (base::FeatureList::IsEnabled(kCobaltBypassMojoForMedia) ||
bypass_mojo_for_media_) {
// URL player is incompatible with the bypass bridge because the bypass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just gate the code by !BUILDFLAG(IS_IOS_TVOS)

@abhijeetk abhijeetk Jul 29, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion!

Gating the bypass bridge block with !BUILDFLAG(IS_IOS_TVOS) would also require gating the related members (bypass_mojo_for_media_, bypass_bridge_, bypass_id_), the static g_next_bypass_id, and the three helper methogs (OnTimeUpdateFromBridge, OnStatisticsUpdateFromBridge OnExtensionBypassInitialized), since they become unused on tvOS and trigger -Werror compile errors.

Let me know if you'd prefer a different approach here.

void PaintVideoHoleFrame(const gfx::Size& size) override;
void UpdateStarboardRenderingMode(const StarboardRenderingMode mode) override;
void GetSbWindowHandle() override;
void OnDurationChange(base::TimeDelta duration) override;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is only used on tvOS, consider to gate them by BUILDFLAG(IS_IOS_TVOS), so it would override on other platforms. Same for OnBufferedTimeRangesChange.

kFrameInjectingDemuxer = 5,
kStreamProviderDemuxer = 6,
kManifestDemuxer = 7,
kUrlPlayerDemuxer = 8, // URL player placeholder demuxer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please gate it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_ios_tvos / is_tvos isn't available as a mojom enabled feature (only is_ios is registered in mojom.gni). Would [EnableIf=is_ios] work as a substitute since it's the closest available flag?

Currently at GN level, we identify tvos code using is_ios && target_platform == "tvos" but we can not use compound conditions with [EnableIf=...]

Please see our previous notes here regarding this constraint.

Aslo, media_types.mojom must stay in sync with demuxer.h and media_types_enum_mojom_traits.h.
The traits file has a switch that maps between ::media::DemuxerType::kUrlPlayerDemuxer (from
demuxer.h) and media::mojom::DemuxerType::kUrlPlayerDemuxer (from generated mojom). If one exists but the other doesn't, compilation fails.

As per your suggestion on demuxer.h to use BUILDFLAG(USE_STARBOARD_MEDIA), it means we need to use [EnableIf=use_starboard_media] here ?

GetSbWindowHandle();

// URL player duration and buffered ranges forwarding.
OnDurationChange(mojo_base.mojom.TimeDelta duration);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please gate it both by use_starboard_media and is_ios_tvos

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed above on media_types.mojom, is_ios_tvos isn't available as a mojom enabled feature.
The interface StarboardRendererClientExtension is already guarded by use_starboard_media, should we use [EnableIf=is_ios] here ?

InitializeWithBypassBridge(uint32 bypass_bridge_id) => (bool success);

// Pass source URL for URL player.
SetSourceUrl(string source_url);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed above on media_types.mojom, is_ios_tvos isn't available as a mojom enabled feature.
The interface StarboardRendererExtension is already guarded by use_starboard_media, should we use [EnableIf=is_ios] here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants